import java.util.Scanner;
import java.util.Random;

import javax.swing.JOptionPane;

public class Challenge8
{
	public static void main(String[] args)
	{
		String guessStr = "Hi";
		int guess = Integer.parseInt(guessStr);
		Random randomNumberGenerator = new Random();
		
		int ranNum = 0;
		JOptionPane.showMessageDialog(null, "Welcome to the Guessing Game!");
		
		while(guess != ranNum)
		{
			String playOrQuit = JOptionPane.showInputDialog(null, "Press (P) to play!\n Press (Q) for the game to glitch out!");
			ranNum = randomNumberGenerator.nextInt(10)+1;
			
			switch(playOrQuit)
			{
				case "P":
				case "p":
					String guess2Str = JOptionPane.showInputDialog(null, "Choose a number from 1-10");
					int guess2 = Integer.parseInt(guess2Str);
					if (guess2 == ranNum)
					{
						JOptionPane.showMessageDialog(null, "CORRECT!");
					}
					else if ((guess != ranNum) && (guess > ranNum))
					{
						JOptionPane.showMessageDialog(null, "Too High!");
					}
					else if ((guess != ranNum) && (guess < ranNum))
					{
						JOptionPane.showMessageDialog(null, "Too Low!");
					}
				case "Q":
				case "q":
					JOptionPane.showMessageDialog(null, "TOO BAD!");
					break;
				default:
					JOptionPane.showMessageDialog(null, "Invalid Selection!");
			}	
		}
	}
}
